import { requestClient } from '#/api/request';

export namespace PublicDataApi {
export interface PublishData {
    userId: string,
    fileId: string,
    name: string,
}
}
// upload
const uploadFile = (userId: string, taskId: string, catalogId: string) => {
    const uploadInfo = {
        userId,
        taskId,
        catalogId,
    };
    return requestClient.post('/dsc-systemMS/dsc-public-resource/file', JSON.stringify(uploadInfo))
}
// getlist--file
const getFileList = (pageSize: number, currentPage: number, keyword: string) => {
    return requestClient.get(`/dsc-systemMS/dsc-public-resource/file/getFileList/${pageSize}/${currentPage}?keyword=${keyword}`)
}
// getlist--vector
const getVecList = (pageSize: number, currentPage: number, keyword: string) => {
    return requestClient.get(`/dsc-systemMS/dsc-public-resource/service/getVecServiceList/${pageSize}/${currentPage}?keyword=${keyword}`)
}
// getlist--raster
const getRasList = (pageSize: number, currentPage: number, keyword: string) => {
    return requestClient.get(`/dsc-systemMS/dsc-public-resource/service/getRasServiceList/${pageSize}/${currentPage}?keyword=${keyword}`)
}
// deletefile
const deleteFile = (fileId: string) => {
    return requestClient.delete(`/dsc-systemMS/dsc-public-resource/file/${fileId}`)
}
// deleteservice
const deleteService = (serviceId: string) => {
    return requestClient.delete(`/dsc-systemMS/dsc-public-resource/service/${serviceId}`)
}
// publish
const publishGeoJSON2VectorS = (data: PublicDataApi.PublishData) => {
    return requestClient.post('/dsc-systemMS/dsc-public-resource/service/publishGeoJSON2VectorS', data)
}
const publishTiff2ImgRasterS = (data: PublicDataApi.PublishData) => {
    return requestClient.post('/dsc-systemMS/dsc-public-resource/service/publishTiff2ImgRasterS', data)
}
// import
const importFile2Resources = (userId: string, fileId: string, catalogId: string) => {
    const data = {
        userId,
        fileId,
        catalogId
    };
    return requestClient.post('/dsc-systemMS/dsc-file/import', data);
}
const importRas2Resources = (userId: string, serviceId: string) => {
    const data = {
        userId,
        serviceId
    };
    return requestClient.post('/dsc-systemMS/dsc-raster-service/import', data);
}
const importVec2Resources = (userId: string, serviceId: string) => {
    const data = {
        userId,
        serviceId
    };
    return requestClient.post('/dsc-systemMS/dsc-vector-service/import', data);
}
export default {
    uploadFile,
    getFileList,
    getVecList,
    getRasList,
    deleteFile,
    deleteService,
    publishGeoJSON2VectorS,
    publishTiff2ImgRasterS,
    importFile2Resources,
    importRas2Resources,
    importVec2Resources
}
